﻿using System;
using System.Collections.Generic;
using System.Text;

namespace PS.DBUtility
{

    /// <summary>
    /// 用户自定义数据库操作
    /// </summary>
    /// <param name="conn"></param>
    /// <param name="trans"></param>
    /// <returns></returns>
    //public delegate Object CustomerDbOperate(SqlConnection conn, SqlTransaction trans);
    public class DBHelperRS : DbHelperSQL, IDisposable
    {
        //数据库连接字符串(web.config来配置)，多数据库可使用DbHelperSQLP来实现.
        //public DbHelperSQL Owner;
        //Owner.connectionString = PubConstant.ConnectionStringRS;
        //DbHelperSQL.connectionString= PubConstant.ConnectionStringRS;
        public DBHelperRS()
        {
            //this.Owner = owner;
            connectionString = PubConstant.ConnectionStringRS;
        }

        static DBHelperRS()
        {
            connectionString = PubConstant.ConnectionStringRS;
        }

        //~DBHelperRS()
        //{
        //    connectionString = PubConstant.ConnectionString;
        //    Dispose(false);
        //}

        public void Dispose()
        {            
            connectionString = PubConstant.ConnectionString;
            Dispose(true); 
            // Take yourself off the Finalization queue 
            // to prevent finalization code for this object
            // from executing a second time.
            GC.SuppressFinalize(this);
        }

        private bool disposed = false;

        //// Pointer to an external unmanaged resource.
        //private IntPtr handle;
        //// Other managed resource this class uses.
        //private Component Components;

        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed 
                //// and unmanaged resources.
                //if (disposing)
                //{
                //    // Dispose managed resources.
                //    Components.Dispose();
                //}
                //// Release unmanaged resources. If disposing is false, 
                //// only the following code is executed.
                //CloseHandle(handle);
                //handle = IntPtr.Zero;
                // Note that this is not thread safe.
                // Another thread could start disposing the object
                // after the managed resources are disposed,
                // but before the disposed flag is set to true.
                // If thread safety is necessary, it must be
                // implemented by the client.

            }
            disposed = true;
        }
    }
}
